﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bai12_shard
{
    public interface ISoSanh
    {
        bool SoSanh(object a);
    }
    public class SinhVien : ISoSanh
    {
        string ten;
        float dtb;
        public string Ten
        {
            get { return ten; }
            set { ten = value; }
        }
        public float Diem
        {
            get { return dtb; }
            set { dtb = value; }
        }
        public SinhVien(string t, float d)
        {
            ten = t; dtb = d;
        }
        public bool SoSanh(object a)
        {
            SinhVien sv = (SinhVien)a;
            if (sv.Diem > dtb)
                return true;
            else
                return false;
        }
    }
    public class SapXep
    {
        public static void SapXepTang(object[] a, int n)
        {
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    ISoSanh x = (ISoSanh)a[i];
                    ISoSanh y = (ISoSanh)a[j];
                    if (x.SoSanh(y) == true)
                    {
                        object t = a[i]; a[i] = a[j]; a[j] = t;
                    }
                }
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            SinhVien[] sv = new SinhVien[10];
            sv[0] = new SinhVien("A", 5);
            sv[1] = new SinhVien("B", 6);
            sv[2] = new SinhVien("C", 3);
            SapXep.SapXepTang(sv, 3);

        }
    }
}
